package com.itheima.service.Impl;

import com.itheima.mapper.DeptMapper;
import com.itheima.pojo.Dept;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
     private DeptMapper deptMapper; //= new DeptDaoImpl();

     public List<Dept> list() throws IOException {return deptMapper.list();}
    @Override
    public void deleteById(Integer id) {
        deptMapper.delete(id);
    }

    @Override
    public void add(Dept dept) {
         dept.setCreateTime(LocalDateTime.now());
         dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);
    }

    @Override
    public Dept selectById(Integer id) {
        return deptMapper.selectById(id);
    }

    @Override
    public void update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
    //    dept.setUpdateTime(null);
        deptMapper.update(dept);
    }
}
